header.row
  .span5
    h3 = t('CronJobs')
- if @cron_jobs.size > 0

  table class="table table-hover table-bordered table-striped"
    thead
      th = t('Status')
      th = t('Name')
      th = t('Cron')
      th = t('Last enque')
      th width="180px"
        = t('Actions')


    - @cron_jobs.sort{|a,b| a.sort_name <=> b.sort_name }.each_with_index do |job, index|
      - style = "#{job.status == 'disabled' ? "background: #ecc": ""}"
      tr
        td[style="#{style}"]= job.status
        td[style="#{style}"]
          b job.name
          hr style="margin:3px;border:0;"
          small
            - if job.message and job.message.to_s.size > 100
              button data-toggle="collapse" data-target=".worker_#{index}" class="btn btn-mini" = t('ShowAll')
              .toggle[class="worker_#{index}" style="display: inline;"]= job.message[0..100] + "... "
              .toggle[class="worker_#{index}" style="display: none;"]= job.message
            - else
              = job.message

        td[style="#{style}"]
          b == job.cron.gsub(" ", "&nbsp;")
        td[style="#{style}"]== job.last_enqueue_time ? relative_time(job.last_enqueue_time) : "-"
        td[style="#{style}"]
          -if job.status == 'enabled'
            form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/enque" method="post"
              = csrf_tag if respond_to?(:csrf_tag)
              input.btn.btn-small.pull-left type="submit" name="enque" value="#{t('EnqueueNow')}"
            form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/disable" method="post"
              = csrf_tag if respond_to?(:csrf_tag)
              input.btn.btn-small.pull-left type="submit" name="disable" value="#{t('Disable')}"
          -else
            form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/enque" method="post"
              = csrf_tag if respond_to?(:csrf_tag)
              input.btn.btn-small.pull-left type="submit" name="enque" value="#{t('EnqueueNow')}"
            form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/enable" method="post"
              = csrf_tag if respond_to?(:csrf_tag)
              input.btn.btn-small.pull-left type="submit" name="enable" value="#{t('Enable')}"
            form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/delete" method="post"
              = csrf_tag if respond_to?(:csrf_tag)
              input.btn.btn-danger.btn-small type="submit" name="delete" value="#{t('Delete')}" data-confirm="#{t('AreYouSureDeleteCronJob', :job => job.name)}"

- else
  .alert.alert-success = t('NoCronJobsFound')
